﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DotNet.Business;

public partial class admin_adminProduct : basePage
{
    #region 初始化变量
    tab_productBll productBll = new tab_productBll();
    tab_productClassBll productClassBll = new tab_productClassBll();
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["action"]!=null)
            {
                string action = Request.QueryString["action"];
                switch (action.Trim())
                {
                    case"del":
                        deleteProduct();
                        break;
                    default:
                        break;
                }
            }            
        }
        bindProduct();
    }

    #region 删除
    /// <summary>
    /// 删除
    /// </summary>
    private void deleteProduct() 
    {
        int productID = Convert.ToInt32(Request.QueryString["pid"]);
        if (!productBll.Delete(productID)) 
        {
            Response.Write("1");
            Response.End();
        }        
    }
    #endregion

    #region 绑定数据
    private void bindProduct() 
    {
        this.rep_product.DataSource = productBll.GetModel();
        this.rep_product.DataBind();
    }
    #endregion

    #region 根据产品类别ID获取类别名称
    public string getProductClassName(int pcid)
    {
        tab_productClass productClassModel = new tab_productClass();
        productClassModel = productClassBll.GetModel(pcid);
        return productClassModel.productClassName;
    }
    #endregion
}
